package com.lz.sentinel.project.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.lz.sentinel.common.entity.RequestVo;
import com.lz.sentinel.common.entity.ResponseVo;
import com.lz.sentinel.common.utils.DateUtils;
import org.springframework.web.bind.annotation.*;

/**
 * MQ生产者
 * @author Administrator
 */
@RestController
@RequestMapping(value = "/otcOption")
public class CalcOtcOptionController {



    @PostMapping("/calc")
    @SentinelResource(value = "otcOption",blockHandler = "handleLeakyBlock")
    public ResponseVo send10(@RequestBody RequestVo requestVo) {
        System.out.println(DateUtils.getCurr_YYYY_MM_DD_HH_MM_SS_SSS() + "：otcOption calc 计算成功");
        return ResponseVo.success("otcOption calc 计算成功");
    }
    public ResponseVo handleLeakyBlock(@RequestBody RequestVo requestVo, BlockException e) {
        System.out.println("Sentinel漏斗算法流量请求频繁，控制了！");
        return ResponseVo.failure("otcOption calc 漏斗算法流量请求频繁，请稍后重试！");
    }

}